#include "CEffect.h"


CEffect::CEffect(): CAnimatedObject()
{
	m_fDeltaTime	= 0.0f;
	m_fTimeLife		= 0.0f;
}

CEffect::CEffect(float Xpos, float Ypos, float deep, float XVelocity, float YVelocity, int width, int height) : CAnimatedObject( Xpos , Ypos , deep , XVelocity , YVelocity , width , height )
{
	m_fDeltaTime	= 0.0f;
	m_fTimeLife		= 0.0f;
}

CEffect::~CEffect()
{

}



//--------------------------------------------------//
// Name : SetTimeLife								//
// Desc : Set the time that this effect last long	//
//--------------------------------------------------//
void CEffect::SetTimeLife(float timeLife)
{
	m_fTimeLife = timeLife;
}




//------------------------------//
// Name : Update				//
// Desc : Update this effect	//
//------------------------------//
void CEffect::Update(float deltaTime)
{
	float moveX;
	float moveY;

	m_fDeltaTime += deltaTime;
	if( m_fDeltaTime >= m_fTimeLife )
		SetAlive( false );

	moveX = GetXVelocity() * deltaTime; 
	moveY = GetYVelocity() * deltaTime;
	Move( moveX , moveY );

	GetSprite()->Update( deltaTime );
}